package com.itcast.demoone.kotlin

fun main() {
    val dog = Dog("旺财")
    dog.makeSound()

    val cat = Cat("小猫")
    cat.makeSound()

}

/**
 * 父类
 */
open class Animal(val name: String) {
    open fun makeSound() {
        println("$name 正在发出声音")
    }
}

/**
 * 子类 - 狗类
 */
class Dog(name: String) : Animal(name) {
    override fun makeSound() {
        super.makeSound()
        println("$name 汪汪汪")
    }
}

/**
 * 子类 - 猫类
 */
class Cat(name: String) : Animal(name) {
    override fun makeSound() {
        super.makeSound()
        println("$name 喵喵喵")
    }
}